package cn.kongwg.juc;

import java.util.concurrent.CountDownLatch;

/**
 * @author kongwg
 * @create 2021-05-01 21:23
 */
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 0; i < 6; i++) {
            final int number = i;
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + number + "离开教室");
                countDownLatch.countDown();
            }, String.valueOf(i).toString()).start();

        }
        countDownLatch.await();
        System.out.println(Thread.currentThread().getName() + "关门");
    }
}
